home *** CD-ROM | disk | FTP | other *** search
- /**************************************************************
- *
- * GRAPHICS.C
- *
- **************************************************************/
-
- #include <acs.h>
- #include <stdlib.h>
- #include <graphics.pif>
-
- #define ELL_STRETCH 1.3 /* manipulation of ellipses in y-direction */
-
-
- /***************/
- void draw_note /*
- ****************/
- (
- int handle, /* VDI workstation handle */
- int *points, /* points[0]: x-value of 1. corner
- points[1]: y-value of 1. corner
- points[2]: x-value of 2. corner
- points[3]: y-value of 2. corner */
- int type, /* see below */
- int style, /* fill style */
- int color /* fill color */
- )
- {
- register int hdl = handle ;
- register int dy = (points[3] - points[1])>>1, dy_ell = (int)( (float)dy * ELL_STRETCH ) ;
- register int y_mean = (points[3] + points[1])>>1 ;
- register int p[6] ;
-
- /*** Lenghty procedure, but optimized for speed ! ***/
-
- if (type & BODY_FRONT)
- {
- p[1] = points[1] - dy ;
- p[3] = points[3] + dy ;
- p[5] = y_mean ;
-
- /*** draw in the background ***/
- vsf_interior(hdl, FIS_SOLID) ;
- vsf_color(hdl, BLACK) ;
-
- /*** draw head ***/
- if (!(type & HEAD_CUT))
- {
- p[2] = p[0] = points[0] ;
- if (type & HEAD_TRI)
- {
- p[2] = p[0] = points[0] ;
- p[4] = p[0] + points[3] - points[1] ;
- v_fillarea(hdl, 3, p) ;
- }
- else if (type & HEAD_LINE) v_pline(hdl, 2, p) ;
- }
- /*** draw tail ***/
- if (!(type & TAIL_CUT))
- {
- if (type & TAIL_TRI)
- {
- p[2] = p[0] = points[2] ;
- p[4] = p[0] - points[3] + points[1] ;
- v_fillarea(hdl, 3, p) ;
- }
- else if (type & TAIL_LINE)
- {
- p[2] = p[0] = points[2] ;
- v_pline(hdl, 2, p) ;
- }
- }
- /*** draw note body in the foreground ***/
- if (!style) vsf_interior(hdl, FIS_HOLLOW) ;
- else
- {
- vsf_interior(hdl, FIS_PATTERN) ;
- vsf_style(hdl, style) ;
- }
- vsf_color(hdl, color) ;
- if (type & BODY_ELLIP)
- {
- if (type & HEAD_CUT)
- {
- v_ellpie(hdl, points[0], y_mean, points[2] - points[0], dy_ell, 2700, 900) ;
- if (color != BLACK)
- {
- vsf_interior(hdl, FIS_HOLLOW) ;
- vsf_color(hdl, BLACK) ;
- vswr_mode(hdl, MD_TRANS) ;
- v_ellpie(hdl, points[0], y_mean, points[2] - points[0], dy_ell, 2700, 900) ;
- vswr_mode(hdl, MD_REPLACE) ;
- }
- }
- else if (type & TAIL_CUT)
- {
- v_ellpie(hdl, points[2], y_mean, points[2] - points[0], dy_ell, 900, 2700) ;
- if (color != BLACK)
- {
- vsf_interior(hdl, FIS_HOLLOW) ;
- vsf_color(hdl, BLACK) ;
- vswr_mode(hdl, MD_TRANS) ;
- v_ellpie(hdl, points[2], y_mean, points[2] - points[0], dy_ell, 900, 2700) ;
- vswr_mode(hdl, MD_REPLACE) ;
- }
- }
- else
- {
- v_ellipse(hdl, (points[0] + points[2])>>1, y_mean, (points[2] - points[0])>>1, dy_ell) ;
- if (color != BLACK)
- {
- vsf_interior(hdl, FIS_HOLLOW) ;
- vsf_color(hdl, BLACK) ;
- vswr_mode(hdl, MD_TRANS) ;
- v_ellipse(hdl, (points[0] + points[2])>>1, y_mean, (points[2] - points[0])>>1, dy_ell) ;
- vswr_mode(hdl, MD_REPLACE) ;
- }
- }
- }
- else if (type & BODY_RECT)
- {
- v_bar(hdl, points) ;
- if (color != BLACK)
- {
- vsf_interior(hdl, FIS_HOLLOW) ;
- vsf_color(hdl, BLACK) ;
- vswr_mode(hdl, MD_TRANS) ;
- v_bar(hdl, points) ;
- vswr_mode(hdl, MD_REPLACE) ;
- }
- }
- }
- else
- {
- /*** draw note body in the background ***/
- vsf_interior(hdl, FIS_SOLID) ;
- vsf_color(hdl, BLACK) ;
- if (type & BODY_ELLIP)
- {
- dy = (points[3] - points[1])>>1 ;
- y_mean = (points[3] + points[1])>>1 ;
- if (type & HEAD_CUT)
- v_ellpie(hdl, points[0], y_mean, points[2] - points[0], dy_ell, 2700, 900) ;
- else if (type & TAIL_CUT)
- v_ellpie(hdl, points[2], y_mean, points[2] - points[0], dy_ell, 900, 2700) ;
- else
- v_ellipse(hdl , (points[0] + points[2])>>1, y_mean, (points[2] - points[0])>>1, dy_ell) ;
- }
- else if (type & BODY_RECT) v_bar(hdl, points) ;
-
- /*** draw tail and head ***/
- p[1] = points[1] - dy ;
- p[3] = points[3] + dy ;
- p[5] = y_mean ;
-
- /*** draw tail ***/
- if (!(type & TAIL_CUT))
- {
- if (type & TAIL_TRI)
- {
- p[2] = p[0] = points[2] ;
- p[4] = p[0] - points[3] + points[1] ;
- if (!style) vsf_interior(hdl, FIS_HOLLOW) ;
- else
- {
- vsf_interior(hdl, FIS_PATTERN) ;
- vsf_style(hdl, style) ;
- }
- vsf_color(hdl, color) ;
- v_fillarea(hdl, 3, p) ;
- if (color != BLACK)
- {
- vsf_interior(hdl, FIS_HOLLOW) ;
- vsf_color(hdl, BLACK) ;
- vswr_mode(hdl, MD_TRANS) ;
- v_fillarea(hdl, 3, p) ;
- vswr_mode(hdl, MD_REPLACE) ;
- }
- }
- else if (type & TAIL_LINE)
- {
- p[2] = p[0] = points[2] ;
- v_pline(hdl, 2, p) ;
- }
- }
- /*** draw head ***/
- if (!(type & HEAD_CUT))
- {
- p[2] = p[0] = points[0] ;
- if (type & HEAD_TRI)
- {
- p[2] = p[0] = points[0] ;
- p[4] = p[0] + points[3] - points[1] ;
- if (!style) vsf_interior(hdl, FIS_HOLLOW) ;
- else
- {
- vsf_interior(hdl, FIS_PATTERN) ;
- vsf_style(hdl, style) ;
- }
- vsf_color(hdl, color) ;
- v_fillarea(hdl, 3, p) ;
- if (color != BLACK)
- {
- vsf_interior(hdl, FIS_HOLLOW) ;
- vsf_color(hdl, BLACK) ;
- vswr_mode(hdl, MD_TRANS) ;
- v_fillarea(hdl, 3, p) ;
- vswr_mode(hdl, MD_REPLACE) ;
- }
- }
- else if (type & HEAD_LINE) v_pline(hdl, 2, p) ;
- }
- }
- }
-
-
- /****************/
- void draw_lines /*
- *****************/
- (
- int handle, /* VDI workstation handle */
- char number, /* number of lines to be drawn */
- char first_marked, /* first line with special marking */
- char d_marked, /* special marking each d_marked lines */
- MARK_MODE mode, /* where to place rectangle marks */
- int styles[12], /* styles to be used after a special line */
- int colors[12], /* colors to be used after a special line */
- char first_number, /* number (text) for first special line */
- int number_dots, /* of special line, no dots if -1 */
- int dx_text, /* text (number) offset from x_start on */
- int dy_text, /* text (number) offset from y_start on */
- int x_start, /* of first line */
- int y_start, /* of first line */
- int x_end, /* of first line */
- int y_end, /* of first_line */
- float dx, /* distance of succeeding lines */
- float dy /* distance of succeeding lines */
- )
- {
- char i, number_offset, k ;
- int points[4], dx_m = (int)(dx * d_marked / 12),
- dy_m = (int)(dy * d_marked / 12) ;
- int x_width, y_width, color, style ;
- char *dummy = "--" ;
-
- number_offset = 11 ;
- color = colors[(first_number + number_offset) % 12] ;
- vsl_color(handle, color) ;
- number_offset = -1 ;
-
- for (i = 0 ; i < number ; i ++ )
- {
- points[0] = (int)(dx * i) + x_start ;
- points[1] = (int)(dy * i) + y_start ;
- points[2] = points[0] + x_end - x_start ;
- points[3] = points[1] + y_end - y_start ;
-
- if (i % d_marked != first_marked) v_pline(handle, 2, points) ;
- else
- {
- /*** switch to next color and style ***/
- number_offset ++ ;
- color = colors[(first_number + number_offset) % 12] ;
- style = styles[(first_number + number_offset) % 12] ;
- vsl_color(handle, color) ;
- vsf_color(handle, color) ;
- vsf_style(handle, style) ;
-
- if (first_marked == -1) v_pline(handle, 2, points) ;
- else
- {
- /*** mark with number ***/
- v_gtext( handle, points[0] + dx_text, points[1] + dy_text,
- itoa(first_number + number_offset, dummy, 12) ) ;
-
- if (style == IP_HOLLOW) vsl_width(handle, 3) ;
- if (number_dots <= 0)
- if (mode == behind)
- {
- /*** mark non-dotted, rectangle behind line ***/
- points[0] += dx_m ; points[1] += dy_m ; points[2] -= dx_m ; points[3] -= dy_m ;
- if (style != IP_HOLLOW) v_bar(handle, points) ;
-
- points[0] -= dx_m ; points[1] -= dy_m ; points[2] += dx_m ; points[3] += dy_m ;
- v_pline(handle, 2, points) ;
- }
- else
- {
- /*** mark non-dotted, rectangle between lines ***/
- points[0] += dx ; points[1] += dy ;
- if (i != number - 1) if (style != IP_HOLLOW) v_bar(handle, points) ;
-
- points[0] -= dx ; points[1] -= dy ;
- v_pline(handle, 2, points) ;
- }
- else
- {
- x_width = ((x_end - x_start) / number_dots) >> 1 ;
- y_width = ((y_end - y_start) / number_dots) >> 1 ;
- for (k = 0 ; k < number_dots ; k++)
- {
- /*** draw dot ***/
- points[0] = (int)(dx * i) + x_start
- + (long)(x_end - x_start) * k / number_dots + dx_m ;
- points[1] = (int)(dy * i) + y_start
- + (long)(y_end - y_start) * k / number_dots + dy_m ;
- points[2] = points[0] + x_width - (dx_m << 1) ;
- points[3] = points[1] + y_width - (dy_m << 1) ;
- if (style != IP_HOLLOW) v_bar(handle, points) ;
-
- points[0] -= dx_m ; points[1] -= dy_m ; points[2] += dx_m ; points[3] += dy_m ;
- v_pline(handle, 2, points) ;
- }
- }
- /*** reset line width ***/
- vsl_width(handle, 1) ;
- }
- }
- }
- }
-